** We Are One: The Social Maintenance of Black Democratic Party Loyalty**
 
// Julian J. Wamble (julianw@gwu.edu) 
// Chryl N. Laird (clarid@bowdoin.edu)
// Corrine M. McConnaughy (corrinem@princeton.edu)
// Ismail K. White (iwhite@princeton.edu)

** Each dataset file in the replication folder already includes the recodes, but if you download the file from another source the recodes are found below. 

//////////////////RECODES////////////////////

***********************************2012 ANES RECODES****************************

*All self-identified blacks
gen blacka= dem_racecps_black
tab blacka

*All self-identified whites
gen whitea= dem_racecps_white

*Black and White Respondents*
gen bw=.
replace bw=1 if blacka==1
replace bw=0 if whitea==1
tab bw

*Dem PID*
gen demind=pid_x
recode demind 4/7=0 1/3=1 -2=.

*Independent PID*
gen indind=pid_x
recode indind 4=1 1/3=0 5/7=0 -2=.

*Republican PID*
gen repind=pid_x
recode repind  5/7=1 1/4=0 -2=.

*online
gen online=mode
recode online 2=1 1=0
tab online

*white int 
gen wiall1=iwrdesc_pre_race_white
recode wiall1 -9/-2=. -1=.

*nonblack Interviewer 
gen oall1=iwrdesc_pre_race_other
recode oall1 -9/-2=. -1=.

*Black Interviewer
 gen biall1=iwrdesc_pre_race_black
recode biall1 -9/-2=. -1=.
tab biall1

*Black Interviewer V. Online*
gen blkonline=. 
replace blkonline=1 if biall1==1
replace blkonline=0 if online==1
tab blkonline

*White Interviewer V. Online*
gen whtonline=. 
replace whtonline=1 if wiall1==1
replace whtonline=0 if online==1
tab whtonline

*Black Interviewer V. White Interviewer*
gen blkwht=.
replace blkwht=1 if biall1==1
replace blkwht=0 if wiall1==1
tab blkwht

*Married*
gen married=dem_marital
recode married -9=. 2/6=0

*Ideology*
gen ideo=libcpre_self
recode ideo -2=3 if libcpre_choose==1
recode ideo -8=3 if libcpre_choose==1
recode ideo -9=3 if libcpre_choose==1
recode ideo -2=5 if libcpre_choose==2
recode ideo -8=5 if libcpre_choose==2
recode ideo -9=5 if libcpre_choose==2
recode ideo 4=3 if libcpre_choose==1
recode ideo 4=5 if libcpre_choose==2
recode ideo -8/-1=4 -9=.
recode ideo 7=0 6=1 5=2 4=3 3=4 2=5 1=6
gen ideo1=ideo/6

gen biall1xideo1=biall1*ideo1
gen wiall1xideo1=wiall1*ideo1

gen ideoa=libcpre_self
recode ideoa -2=3 if libcpre_choose==1
recode ideoa -8=3 if libcpre_choose==1
recode ideoa -9=3 if libcpre_choose==1
recode ideoa -2=5 if libcpre_choose==2
recode ideoa -8=5 if libcpre_choose==2
recode ideoa -9=5 if libcpre_choose==2
recode ideoa 4=3 if libcpre_choose==1
recode ideoa 4=5 if libcpre_choose==2
recode ideoa -8/-1=4 -9=4
recode ideoa 7=0 6=1 5=2 4=3 3=4 2=5 1=6
gen ideoa1=ideoa/6

gen biall1xideoa1=biall1*ideoa1
gen wiall1xideoa1=wiall1*ideoa1

**Interviewer Gender**
gen intgen=iwrdesc_pre_gender
recode intgen 2=1 1=0 -1=. -9/-2=.

**Age**
gen age=dem_age_r_x
recode age -2=.

**Female**
gen female=gender_respondent_x
recode female 2=1 1=0 

**South**
gen south=sample_region
recode south 3=1 1/2=0 4=0

*Economic Regulation/ Free Market Ideology* 
gen nogov=govrole_market
recode nogov 2=1 1=0 -9/-1=.

gen regulate=govrole_regbus
recode regulate -9/-1=. 1=0 2=.25 3=.5 4=.75 5=1

gen noregsc=(regulate+nogov)/2

*Moral Ideology*
 gen moralt=trad_adjust
recode moralt 5=1 4=.75 3=.5 2=.25 1=0 -9/-1=.

gen newl=trad_lifestyle
recode newl 5=0 4=.25 3=.5 2=.75 1=1 -9/-1=.

gen tradt=trad_tolerant
recode tradt 5=1 4=.75 3=.5 2=.25 1=0 -9/-1=.


gen tradf=trad_famval
recode tradf 5=0 4=.25 3=.5 2=.75 1=1 -9/-1=.

alpha moralt newl tradt tradf if black==1, item

gen moral=(moralt+ newl+ tradt+ tradf)/4

*importance of being black*
gen bimp=ident_blackid
recode bimp 2=.75 3=.5 4=.25 5=0 -9/-1=.

*********************************2016 ANES RECODES******************************
*Race- Black Identication*
gen black=V161310b
recode black -9/-1=.
tab black

gen race=V161310x
recode race -9=. 3=. 4=. 5=3 6=.

*Democrat*
gen pid=V161158x
recode pid -9/0=.

gen demind=pid
recode demind 1/3=1 4/9=0

*BLF
gen blf=V161126
recode blf 4=0 3=.33 2=.66  -9/0=.

*Ideology*
drop ideo ideo1
gen ideo=V161126
recode ideo 99=3 if V161127==1
recode ideo -8=3 if V161127==1
recode ideo -9=3 if V161127==1
recode ideo 99=5 if V161127==2
recode ideo -8=5 if V161127==2
recode ideo -9=5 if V161127==2
recode ideo 4=3 if V161127==1
recode ideo 4=5 if V161127==2
recode ideo -8/-1=4 99=4 -9=.
recode ideo 7=0 6=1 5=2 4=3 3=4 2=5 1=6
gen ideo1=ideo/6

*Age*
gen age=V161267c
recode age -9/0=.
gen age1=2016-age

*Married*
gen married=V161268
recode married 1/2=1 -9=. 3/6=0

*Female*
gen female=V161002
recode female -1=. 2=1 1=0
recode female -1=. 2=1 1=0
recode female .=1 if V161342==2
recode female .=0 if V161342==1
recode female .=.5 if V161342==3

*Education*
gen edu=V161270
recode edu -9/0=. 90/95=.

***********************48-12 CUMULATIVE ANES FILE RECODES***********************
*Race
gen race=VCF0105a
recode race 4=. 5=4 6=. 7=. 9=.
 
gen asian=VCF0105a
recode asian  3=1  9=. else=0

gen black=VCF0105a
recode black 2=1  9=. else=0

gen white=VCF0105a
recode white 1=1  9=. else=0

gen hispanic=VCF0105a
 recode hispanic  5=1  9=. else=0

gen college=VCF0140
recode college 9=. 5/6=1 1/4=0

gen bw=.
replace bw=1 if black==1
replace bw=0 if white==1
tab bw

*face to face
gen ftf=VCF0017
recode ftf 0=1 1=0 2=1 3=0 4=0

* pre---PID
gen pid=VCF0301
recode pid 0=. 2=.83 3=.66 4=.5 5=.33 6=.16 7=0

gen demind= VCF0303
recode demind 1=1 2/3=0

gen dem=VCF0302
recode dem 5=1 else=0

gen repind=VCF0303
recode repind 3=1 else=0

gen indind=VCF0303
recode indind 0=1 2=1 1=0 3=0

**Age**
gen age=VCF0101	
recode age 0=.

***Sex***
gen female=VCF0104
recode female 2=1 1=0

****South****
gen south=VCF0112
recode south 3=1 1/2=0 4=0

*Married*
gen married=VCF0147
recode married 2/9=0

*Year*
gen year= VCF0004

*Interviewer Gender*
gen intgen=VCF0070a

*Ideology*
gen ideo=VCF0803
recode ideo 7=0 6=1 5=2 4=3 3=4 2=5 1=6 0=. 9=.
gen ideo1=ideo/6

gen ideo1xblackint=ideo1*blackintall

*Year Dummy*
gen y1988=year
gen y1992=year
gen y1996=year
gen y2000=year
gen y2008=year
gen y2012=year

recode y1988 1988=1 else=0
recode y1992 1992=1 else=0
recode y1996 1996=1 else=0
recode y2000 2000=1 else=0
recode y2008 2008=1 else=0
recode y2012 2012=1 else=0

gen decade =year
recode decade 1940/1949=1940 1950/1959=1950 1960/1969=1960 1970/1979=1970 1980/1989=1980 1990/1999=1990 2000/2009=2000 2010/2019=2010

***********************************PEW RECODES**********************************
*Black Racial Identity*
gen blacki=irace
recode blacki 1=0 2=1 else=.

recode blacki .=1 if iracecmb==2
recode blacki .=0 if iracecmb==1

recode blacki .=1 if  irace1_1==2
recode blacki .=0 if  irace1_1==1

recode blacki .=1 if  irace1_2==2
recode blacki .=0 if  irace1_2==1

recode blacki .=1 if  irace1_3==2
recode blacki .=0 if  irace1_3==1

recode blacki .=1 if  irace1m1==2
recode blacki .=0 if  irace1m1==1

recode blacki .=1 if  irace1m2==2
recode blacki .=0 if  irace1m2==1

recode blacki .=1 if  irace1m3==2
recode blacki .=0 if  irace1m3==1

recode blacki .=1 if  irace1m4==2
recode blacki .=0 if  irace1m4==1

gen black1=racecmb
recode black1 2=1 1=0 else=.
reode black1 0=1 if race1==2
recode black1 0=1 .=1 if race1==2
recode black1 0=1 .=1 if race2==2
recode black1 0=1 .=1 if race3==2
recode black1 0=1 .=1 if race4==2

recode black1 0=1 .=1 if race1_1==2
recode black1 0=1 .=1 if race1_2==2
recode black1 0=1 .=1 if race1_3==2

recode black1 0=1 .=1 if race_1==2
recode black1 0=1 .=1 if race_2==2
recode black1 0=1 .=1 if race_3==2

recode black1 0=1 .=1 if racem1==2
recode black1 0=1 .=1 if racem2==2
recode black1 0=1 .=1 if racem3==2

recode black1 0=1 .=1 if race1m1==2
recode black1 0=1 .=1 if race1m2==2
recode black1 0=1 .=1 if race1m3==2

recode black1 0=1 .=1 if race3m1==2
recode black1 0=1 .=1 if race3m2==2
recode black1 0=1 .=1 if race3m3==2

*Democratic Affiliation*
gen demind1=party
recode demind1 2=1 1=0 else=3
recode demind1 3=1 if partyln==2
recode demind1 3=0 if partyln==1
recode demind1 3=0 if partyln==9
recode demind1 3=0 if partyln==3 
recode demind1 3=0 if partyln==7
recode demind1 3=0 if partyln==8
recode demind1 3=.

gen pid=party
recode pid 1=1 2=3 else=2
recode pid 2=1 if partyln==1
recode pid 2=3 if partyln==2
tab pid, gen(pid)

gen dem=party
gen rep=party

recode dem 2=1 else=0
recode rep 1=1 else=0

gen pid=party
recode pid

gen libcon=ideo
recode libcon 8/9=.

gen bw=.
replace bw=0 if white==1
replace bw=1 if black1==1
tab bw

***********************************GALLUP RECODES*******************************
gen blackint=intrace
recode blackint 1=9 2=9 if	year<=2014	&	month==9

recode blackint 1=9 2=9 if	year<=2014	&	month==8

recode blackint 1=9 2=9 if	year<=2014	&	month==7

recode blackint 1=9 2=9 if	year<=2014	&	month==6

recode blackint 1=9 2=9 if	year<=2014	&	month==5

recode blackint 1=9 2=9 if	year<=2014	&	month==4

recode blackint 1=9 2=9 if	year<=2014	&	month==3

recode blackint 1=9 2=9 if	year<=2014	&	month==2

recode blackint 1=9 2=9 if	year<=2014	&	month==1

recode blackint 6=1 7=2
recode blackint 2=1 1=0 else=.

recode blackint .=0 if intracen==1
recode blackint .=1 if intracen==2
recode blackint .=0 if intracew==1
recode blackint .=1 if intraceb==1
tab blackint

**Republican Affiliation w/Leaners**
gen replean=party
recode replean 1/2=1 else=0
tab replean
**Independent Affiliation no Leaners**
gen independent=party
recode independent 3=1 else=0
tab independent
**Democratic Affiliation w/ Leaners**
gen demlean=party
recode demlean 4/5=1 else=0
tab demlean

*Black Respondents*
gen black=raceban2
recode black 2=1 4=1 1=0 else=.

*White Respondents*
gen white=raceban2
recode white 2=0 4=0 1=1 3=1 else=.
tab white

*Black/White Respondent Variable*
gen bw=.
replace bw=1 if black==1
replace bw=0 if white==1
tab bw

***********************************GSS RECODES**********************************
gen black=race
recode black 1=0 2=1 3=0

gen white=race 
recode white 1=1 2=0 3=0

gen bw=.
replace bw=1 if black==1
replace bw=0 if white==1

gen dem1=partyid
recode dem1 2/9=0  0/1=1

gen demind=partyid
recode demind 3/9=0  0/2=1

gen indind=partyid
recode indind 1/2=0 3=1 4/10=0

gen repind=partyid
recode repind  0/3=0 4/6=1 7/9=0

gen pid=partyid
recode pid 0=6 1=5 2=4 3=3 4=2 5=1 6=0 7=3
gen pid1=pid/6

gen ideology=polviews-1
tab ideology

gen ideoa= polviews
recode ideoa 0=. 
recode ideoa 1=6 2=5 3=4 4=3 5=2 6=1 7=0 8/9=3
gen ideo1a=ideoa/6

gen blackint=intethn
recode blackint 2=1 1=0 0=. 3/4=0 5=.
 
gen ideo1xblackint=blackint*ideo1
gen ideo1axblackint=blackint*ideo1a

gen married= absingle
recode married 0=. 2=1 0=. 1=0 8/9=.

gen year04=year
gen year06=year
gen year08=year
gen year10=year
gen year12=year
gen year14=year
gen year16=year
recode year04 2004=1 else=0
recode year06 2006=1 else=0
recode year08 2008=1 else=0
recode year10 2010=1 else=0
recode year12 2012=1 else=0
recode year14 2014=1 else=0
recode year16 2016=1 else=0
